package io.renren.modules.avanotes.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.vo.output.EchartsGraphXYVo;
import io.renren.modules.avanotes.entity.ScheduleSummaryEntity;
import io.renren.modules.avanotes.entity.SpecialSubjectAchivementEvaluationEntity;
import io.renren.modules.avanotes.service.ScheduleSummaryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Arrays;
import java.util.Map;


/**
 * 计划总结表
 *
 * @author zzr
 * @email 529742454@qq.com
 * @date 2022-02-25 22:26:47
 */
@RestController
@RequestMapping("avanotes/schedulesummary")
//@Api("计划总结表接口")
public class ScheduleSummaryController {
    @Autowired
    private ScheduleSummaryService scheduleSummaryService;

    //region 自定义业务

    /**
     * 新增
     */
    @PostMapping("/insert")
    //@RequiresPermissions("avanotes:specialsubjectachivmentevaluation:save")
    @ApiOperation("新增")
    public R insert(@RequestBody ScheduleSummaryEntity param) {
        Integer id= scheduleSummaryService.insert(param);

        return R.ok().setData(id);
    }


    /**
     * 信息
     */
    @GetMapping("/infoByScheduleId/{id}")
    //@RequiresPermissions("avanotes:schedulesummary:info")
    @ApiOperation("根据 计划/任务ID 查询单条总结详情")
    public R infoByScheduleId(@PathVariable("id") Integer id) {
        ScheduleSummaryEntity scheduleSummary = scheduleSummaryService.infoByScheduleId(id);

        //return R.ok().put("scheduleSummary", scheduleSummary);
        return R.ok().setData(scheduleSummary);
    }

    /**
     * 后端直接组装数据 dataSet（二维数组）
     * @return
     */
    @PostMapping("/aggPersonal")
    //@RequiresPermissions("avanotes:schedulesummary:info")
    @ApiOperation("获取个人学习情况图表")
    public R aggPersonal() {
        EchartsGraphXYVo vo =scheduleSummaryService.aggPersonal();
        return R.ok().setData(vo);
    }

    //endregion

    /**
     * 列表
     */
    @PostMapping("/list")
    //@RequiresPermissions("avanotes:schedulesummary:list")
    //@ApiImplicitParams({
    //        @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "String"),
    //        @ApiImplicitParam(name = "limit", value = "每页记录数", paramType = "query", dataType = "String"),
    //        @ApiImplicitParam(name = "key", value = "检索关键字", paramType = "query", dataType = "String")
    //})
    //@ApiOperation("查询列表")
    public R list(@ApiIgnore @RequestParam Map<String, Object> params) {
        PageUtils page = scheduleSummaryService.queryPage(params);

        //return R.ok().put("page", page);
        return R.ok().setData(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("avanotes:schedulesummary:info")
    //@ApiOperation("查询单条")
    public R info(@PathVariable("id") Integer id) {
        ScheduleSummaryEntity scheduleSummary = scheduleSummaryService.getById(id);

        //return R.ok().put("scheduleSummary", scheduleSummary);
        return R.ok().setData(scheduleSummary);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("avanotes:schedulesummary:save")
    //@ApiOperation("保存")
    public R save(@RequestBody ScheduleSummaryEntity scheduleSummary) {
        scheduleSummaryService.save(scheduleSummary);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    //@RequiresPermissions("avanotes:schedulesummary:update")
    //@ApiOperation("修改")
    public R update(@RequestBody ScheduleSummaryEntity scheduleSummary) {
        scheduleSummaryService.updateById(scheduleSummary);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    //@RequiresPermissions("avanotes:schedulesummary:delete")
    //@ApiOperation("删除")
    public R delete(@RequestBody Integer[] ids) {
        scheduleSummaryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
